package com.yjt.fresh.adpater;

import android.support.annotation.Nullable;
import android.text.Html;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yjt.fresh.R;
import com.yjt.fresh.bean.BeanNews;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.List;

/**
 *
 * @author mcc
 * @date 2018/6/10
 */

public class AdpRvMainAtyInfoPage extends BaseQuickAdapter<BeanNews, BaseViewHolder> {
    public AdpRvMainAtyInfoPage(int layoutResId, @Nullable List<BeanNews> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, BeanNews item) {
        TextView tvTime = helper.getView(R.id.tvAPPItemInfoPageTime);
        TextView tvContent = helper.getView(R.id.tvAPPItemInfoPageContent);
        ImageView iv = helper.getView(R.id.ivAPPItemInfoPage);

        long time = 0;
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {
            time = simpleDateFormat.parse(item.getCREATETIME()).getTime();
        } catch (ParseException e) {
            e.printStackTrace();
        }
        long timeDistance = Math.abs(time - System.currentTimeMillis());
        tvTime.setText(item.getCREATETIME());
        if (item.getTITLE() != null) {
            tvContent.setText(item.getTITLE());
        }
        Glide.with(mContext).load(item.getCOVERIMAGE()).placeholder(R.mipmap.i_banner).into(iv);

    }
}
